<?php

namespace App\Models\Shop;

use App\Models\BaseModel;

class ShopGirl extends BaseModel
{

    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $guarded = [];

    /**
     * The attributes excluded from the model's JSON form.
     *
     * @var array
     */
    protected $hidden = [
        'created_at',
        'updated_at',
    ];

    protected $table = 'shop_girls';
    protected $dateFormat = 'U';

    public function getGirls($shop_id, $page, $size){
        $data['list'] = $this->where('shop_id', $shop_id)->with('tags')
            ->where('status', 1)->forPage($page, $size+1)
            ->get();
        $data['next_page'] = $page + 1;
        $data['page_size'] = $size;
        return $this->after($data);
    }

    public function tags(){
        return $this->hasMany('App\Models\Tag\GirlTagDetail', 'girl_id', 'id');
    }

}
